<!-- delete confirmation dialog box -->
<!--<div id="delConfDialog" class="bank_del" title="Confirm">
    <p>Are you sure?</p>
</div>
<!-- message dialog box -->
<div id="msgDialog" class="bank_msg"><p></p></div>

<script type="text/template" id="bank_readTemplate">
        <tr id="${bank_account_id}">
				<td width="30px">${nomor}</td>
				<td>${name}</td>
				<td>${branch}</td>
                <td>${acc_name}</td>
                <td>${acc_number}</td>
				<td width="110px"><a class="updateBtn" href="${bankUpdateLink}">Edit</a> | <a class="deleteBtn" href="${bankDeleteLink}">Delete</a></td>
        </tr>
</script>

<script type="text/javascript">
var readUrl_bank   = 'index.php/act_banks/read/'+["<?php echo $this->uri->segment(4);?>"],
    bankUpdateUrl = 'index.php/master/'+["<?php echo $this->uri->segment(2);?>"]+'/bank/update',
    bankDelUrl    = 'index.php/act_banks/delete/'+["<?php echo $this->uri->segment(2);?>"]+'/',
    delHref,
    updateHref,
    updateId,
	bank_datatable;

$( document ).ready( function() {
    readBanks();

	$( 'div.bank_msg' ).dialog({
        autoOpen: false,
        buttons: {
            'Ok': function() {
                $( this ).dialog( 'close' );
            }
        }
    });
    
    $( 'div.bank_del' ).dialog({
        autoOpen: false,
        buttons: {
            'No': function() {
                $( this ).dialog( 'close' );
            },
            'Yes': function() {
                //display ajax loader animation here...
                $( 'div.bank_ajaxLoadAni' ).fadeIn( 'slow' );
				
                $( this ).dialog( 'close' );
                $.ajax({
                    url: delHref,
                    success: function( response ) {
                        //hide ajax loader animation here...
                        $( '#div.bank_ajaxLoadAni' ).fadeOut( 'slow' );
                        
                        $( 'div.bank_msg > p' ).html( response );
                        $( 'div.bank_msg' ).dialog( 'option', 'title', 'Success' ).dialog( 'open' );
                        
                        $( 'a[href=' + delHref + ']' ).parents( 'tr' )
                        .fadeOut( 'slow', function() {
                            $( this ).remove();
                        });
                        
                    } //end success
                });
            } //end Yes
        } //end buttons
    }); //end dialog
    
    
    $( 'table.bank_records' ).delegate( 'a.deleteBtn', 'click', function() {
        delHref = $( this ).attr( 'href' );
        $( 'div.bank_del' ).dialog( 'open' );
            return false;
    }); //end delete delegate
    // --- Create Record with Validation ---
}); //end document ready


function readBanks() {
    //display ajax loader animation
	$( 'div.bank_ajaxLoadAni' ).fadeIn( 'slow' );
    
    $.ajax({
        url: readUrl_bank,
        dataType: 'json',
        success: function( response ) {
			
            var j=1;
            
			for( var i in response ) {
                response[ i ].bankUpdateLink = bankUpdateUrl + '/' + response[ i ].bank_account_id;
                response[ i ].bankDeleteLink = bankDelUrl +  '/'  + response[ i ].bank_account_id;
                response[ i ].nomor = j;
                j++;
            }
            //clear old rows
            $( 'table.bankRecords > tbody' ).html( '' );
            
            $( '#bank_readTemplate' ).render( response ).appendTo( "table.bankRecords > tbody" );
            //append new rows
            
            //apply dataTable to #records table and save its object in dataTable variable
            if( typeof bank_dataTable == 'undefined' )
			{
				/*$("table.bankRecords tbody").click(function(event) {
				$(bank_dataTable.fnSettings().aoData).each(function (){
					$(this.nTr).removeClass('row_selected');
				});
				$(event.target.parentNode).addClass('row_selected');
			});
			
			/* Add a click handler for the delete row */
				/*$('#delete').click( function() {
					var anSelected = fnGetSelected( bank_dataTable );
					bank_dataTable.fnDeleteRow( anSelected[0] );
				} );*/
                
				bank_dataTable = $( 'table.bankRecords' ).dataTable({
					"bJQueryUI": true
				});
			}
			
            //hide ajax loader animation here...
            $( 'div.bank_ajaxLoadAni' ).fadeOut( 'slow' );
		}
    });
	
}// end readUsers

/*function fnClickAddRow() {
    $('table.bankRecords').dataTable().fnAddData( ['','','',''] );
     
    giCount++;
}

function deleteRow()
{
	var selected = fnGetSelected(bank_datatable);
	bank_datatable.fnDeleteRow(selected[0]);
}

function fnGetSelected( bank_datatable )
{
	var result = new Array();
	var nodes = bank_datatable.fnGetNodes();
	
	for ( var i=0 ; i<nodes.length ; i++ )
	{
		if ( $(nodes[i]).hasClass('row_selected') )
		{
			result.push( nodes[i] );
		}
	}
	return result;
}*/
</script>